package pe.com.bn.sach.dao.impl;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.ibatis.sqlmap.client.SqlMapClient;

import pe.com.bn.sach.dao.PromotorDAO;
import pe.com.bn.sach.domain.Bnchf15Agencia;
import pe.com.bn.sach.domain.Bnchf37Promotor;

public class PromotorImpl implements PromotorDAO {

	
	protected SqlMapClient sqlMap = null;
	
	public void setSqlMap(SqlMapClient sqlMap) {
		this.sqlMap = sqlMap;
	}
	protected final Log logger = LogFactory.getLog(getClass());
	public List listAgencia() throws Exception{
		return sqlMap.queryForList("sqlAgencia.listaAgencia","");
	}
	
	public void GuardaAgencia(Bnchf15Agencia bnchf15Agencia)throws Exception{
		try{
			sqlMap.startTransaction();
			sqlMap.insert("sqlAgencia.GuardaAgencia",bnchf15Agencia);
			sqlMap.commitTransaction();
		}catch(Exception e){
			e.printStackTrace();
			throw e;
		}finally{
			sqlMap.endTransaction();
		}
	}
	
	
	public List buscarPromotor(Bnchf37Promotor bnchf37Promotor) throws Exception{
		//List lis= ArrayList;
		return sqlMap.queryForList("sqlPromotor.listaPromotor",bnchf37Promotor);
	}
	public Bnchf37Promotor encontrarPromotor(Bnchf37Promotor bnchf37Promotor) throws Exception{
		//List lis= ArrayList;
		List l = sqlMap.queryForList("sqlPromotor.encontrarPromotor",bnchf37Promotor);
		bnchf37Promotor = (Bnchf37Promotor)l.get(0);
		return bnchf37Promotor;
	}
	
}
